<?php
// <copyright file="AuthenticationType.cs" company="NQtec">
// Copyright (c) 2008, 2009 All Right Reserved, http://www.dqer.com/
// Copyright (c) 2008, 2009 All Right Reserved, http://www.nqtec.com/
//
// This source is part of the DQER library that released under the LGPL.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Victor Gatkov</author>
// <email>v.gatkov@nqtec.com</email>
// <email>info@dqer.com</email>
// <date>2008-09-11</date>
// <summary>Contains a base, abstract class for an AuthorisationPolicyProvider</summary>

define('PGID','install');           // set page name as PaGeID
define('PGTP','install');         // set page type as PaGeTyPe render/form/com/etc..
define('ROOT_PATH','../');        // may need to change path to site root from here
define('SRC_PATH',ROOT_PATH.'_');
define('IN_DQER_003311',true);

define ('DEBUG_LEVEL', 0); //0=production, 1=php errors, 2=php+engine raports

require_once(SRC_PATH."/index.php");

 $tts = time();
 $auid = substr(md5(uniqid(rand(),true)),rand(2,12),16);

 $render->page_open();

 if ($database->table_exists('pdata')) {
  echo "Already installed. If you wish to reinstall it, please truncate your database.";
 } else {
  echo "Installation sequence begin..<br /><br />";

  $q = "CREATE TABLE IF NOT EXISTS `pdata` (
  `idn` int(11) NOT NULL auto_increment,
  `uid` varchar(16) NOT NULL,
  `data` varchar(255) NOT NULL default '',
  `type` varchar(8) NOT NULL default 'NODATA',
  `priv` tinyint(1) NOT NULL default '0',
  `conf` tinyint(1) NOT NULL default '0',
  `ts` int(11) unsigned NOT NULL default '0',
  `nts` int(11) unsigned NOT NULL default '0',
  PRIMARY KEY  (`idn`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4; ";
  $database->do_query($q);

  $q = "INSERT INTO `pdata` (`idn`, `uid`, `data`, `type`, `priv`, `conf`, `ts`) VALUES
(1, '".$auid."', 'admin', 'uname', 0, 0, ".$tts."),
(2, '".$auid."', '24', 'ulevel', 0, 0, ".$tts."),
(3, '".$auid."', '8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918', 'pword', 0, 0, ".$tts."); ";
  $database->do_query($q);

  $q = "CREATE TABLE IF NOT EXISTS `ulog` (
`idn` int(11) NOT NULL auto_increment, 
`uid` varchar(16) NOT NULL default '', 
`action` varchar(8) NOT NULL default 'NOTHING', 
`status` varchar(4) NOT NULL default 'ZERO', 
`ip_from` varchar(127) NOT NULL default '127.0.0.1', 
`ts` int(11) unsigned NOT NULL, PRIMARY KEY  (`idn`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; ";
  $database->do_query($q);

  echo "Installation sequence completed successfully..<br /><br /> You may signin as admin with password admin. Don't forget to change it! Please proceed <a href='".ROOT_PATH."sign/'>here</a>";

 }

$render->br(5);
 $render->page_close();
?>
